package semana2.bucles.ejercicio19_Factorial;

import java.util.Scanner;

public class Factorial {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n;
		int acc = 1;
		do {
			System.out
					.println("Introduce un numero entre 1 y 7 (cero para terminar)");
			n = scan.nextInt();
			if (n != 0) {
				if (n >= 1 && n <= 7) {
					System.out.print("El factorial de " + n + " es: ");
					for (int i = n; i > 0; i--) {
						acc = acc * i;
					}
					System.out.println(acc);
				} else {
					System.out.println("Introduce un numero dentro del rango.");
				}
			}
			acc = 1;
		} while (n != 0);
		System.out.println("Adios!!");
	}

}
